//
//  DXTableView.h
//  dangxiao_new
//
//  Created by 段帅 on 16/9/27.
//  Copyright © 2016年 newfuture. All rights reserved.
//首页 分类  搜索  排行 我的课程  我的收藏  我的笔记  所有列表都复用的这个列表

#import <UIKit/UIKit.h>
#import <dangxiao_public/dangxiao_public.h>
#import "SearchRequestModel.h"
#import "BlankView.h"
@protocol DXTableDelegate <NSObject>



@optional
/**
 @数据请求成功 回调数据
 */
-(void)DXTableDidLoadDataSucess:(NSDictionary *)data currentPage:(NSInteger)page WithTable:(UITableView *)table; 
/**
 @空白页显示
 */
-(void)DXTableShowBlankView:(BOOL)Bool withTabel:(UITableView *)table;
/**
 @点击cell
 */
-(void)DXTableDidSelectCellWithCellModel:(NSArray *)data Index:(NSIndexPath *)indexPath withTable:(UITableView *)table;

/**
 @触摸DXTableview的时候
 */
-(void)DXTouchViewBegain;

/**
 @再给model赋值的时候调用  
 */
-(DXModel *)DXInitModel:(NSInteger)num withModel:(DXModel *)model;

-(CGFloat)DXtableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
-(CGFloat)DXtableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

-(UIView *)DXtableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
- (NSInteger)DXtableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (NSInteger)DXnumberOfSectionsInTableView:(UITableView *)tableView;  //默认 返回1 
//默认返回_data[index.row]  返回自定义 data 选项
- (DXModel *)DXtableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath Data:(NSArray *)data;

-(DXModel *)DXtableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath Data:(NSArray *)data;

- (NSString *)DXtableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath;
//请求数据结束
-(void)DXTableDidFinishLoadData;

/**
 tableView滚动代理

 @param tableView <#tableView description#>
 @param num <#num description#>
 */
- (void)DXscrollViewDidScroll:(UIScrollView *)scrollView;                                               // any offset changes
- (void)DXscrollViewDidZoom:(UIScrollView *)scrollView NS_AVAILABLE_IOS(3_2); // any zoom scale changes

// called on start of dragging (may require some time and or distance to move)
- (void)DXscrollViewWillBeginDragging:(UIScrollView *)scrollView;
// called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest
- (void)DXscrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset NS_AVAILABLE_IOS(5_0);
// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
- (void)DXscrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

- (void)DXscrollViewWillBeginDecelerating:(UIScrollView *)scrollView;   // called on finger up as we are moving
- (void)DXscrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll view grinds to a halt

- (void)DXscrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating

- (nullable UIView *)DXviewForZoomingInScrollView:(UIScrollView *)scrollView;     // return a view that will be scaled. if delegate returns nil, nothing happens
- (void)DXscrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view NS_AVAILABLE_IOS(3_2); // called before the scroll view begins zooming its content
- (void)DXscrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale; // scale between minimum and maximum. called after any 'bounce' animations

- (BOOL)DXscrollViewShouldScrollToTop:(UIScrollView *)scrollView;   // return a yes if you want to scroll to the top. if not defined, assumes YES
- (void)DXscrollViewDidScrollToTop:(UIScrollView *)scrollView;      // called when scrolling animation finished. may be called immediately if already at top
@end



@interface DXTableView : UITableView

@property (nonatomic,copy) NSString *url; //请求网址
@property (nonatomic,copy) NSString *url_dele;//删除网址

@property (nonatomic,strong) Class cell;  //cell的类名
@property (nonatomic,strong) Class model; //model的类名
@property (nonatomic, weak)  id<DXTableDelegate> DXdelegate;


@property (nonatomic,strong) SearchRequestModel *request_Model;//发起请求需要的参数

@property (nonatomic,strong)  BlankView *blankView;  //空白页
@property (nonatomic,strong) NSMutableArray     * data;//数据源

/**
 @开始加载数据
 */
-(void)loadData;
/**
 @关闭上拉刷新   默认开启
 */
-(void)closeRefresh;




/**
 @将model值传向cell  这是必须实现的block
 */
@property (nonatomic, copy) void (^cellLoadData)(UITableViewCell *cell,DXModel *model);
/**
 @回调删除的值   左滑删除必须实现的block
 */
@property (nonatomic, copy) NSDictionary* (^cellCanMove)(DXModel *model);

/**
 @数据源回调block  针对需要对解析回来的数据做特殊处理
 */
@property (nonatomic, copy) NSArray* (^dataCallBack)(NSMutableArray *data);

/**
 @上啦刷新和 下拉加载 走这两个block
 */
@property (nonatomic, copy) void (^loadDataUp)(void);
@property (nonatomic, copy) void (^loadDataDown)(NSInteger page);
/**
 是否显示等待加载  默认不显示
 */
@property (nonatomic,assign) BOOL     isShowHud;

@end
